package org.csu.onlineedubackend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.csu.onlineedubackend.entity.Question;

import java.util.List;
import java.util.Map;

@Mapper

public interface QuestionMapper extends BaseMapper<Question> {
    // 如果有自定义SQL，可以在这里加方法

    /**
     * 獲取課程的所有作業
     * @param courseId 課程ID
     * @return 作業列表
     */
//    @Select("SELECT q.id, q.content as title, q.content FROM question q")
//    List<Map<String, Object>> getQuestionsByCourseId(Long courseId);
    @Select("SELECT q.id, q.title as title, q.content, q.course_id FROM question q WHERE q.course_id = #{courseId}")
    List<Map<String, Object>> getQuestionsByCourseId(Long courseId);
}
